package cn.timelost.hr.config.utils;

import java.sql.Date;
import java.sql.Time;
import java.time.LocalTime;

/**
 * 计算当前时间
 */
public class SysTime {
    public Date getDate(){
        java.util.Date date1=new java.util.Date();
        Date date=new Date(date1.getTime());
        return date;
    }
    public Time getTime(){
        java.util.Date date1=new java.util.Date();
        Time timer=new Time(date1.getTime());
        return timer;
    }
    public Date getTurnDate(java.util.Date date1){
        if(date1==null)return null;
        Date date=new Date(date1.getTime());
        return date;
    }
    public Time getTurnTime(java.util.Date date1){
        if(date1==null)return null;
        Time timer=new Time(date1.getTime());
        return timer;
    }

    /**
     * 判断签到
     * @return
     */
    public int judge(){
        LocalTime signTime=LocalTime.now();
        LocalTime localTime2=LocalTime.parse("09:00:00");//
        LocalTime localTime3=localTime2.plusHours(2);
        if(signTime.isBefore(localTime2)){
            return 0;//正常
        }else if(signTime.isBefore(localTime3)){
            return 1;//迟到
        }else {
            return 2;//缺勤
        }
    }

    /**
     * 判断签退
     * @return
     */
    public int judge2(){
        LocalTime signTime=LocalTime.now();
        LocalTime localTime2=LocalTime.parse("21:00:00");//
        LocalTime localTime3=localTime2.plusHours(2);
        if(signTime.isBefore(localTime2)){
            return 0;//正常
        }else if(signTime.isBefore(localTime3)){
            return 1;//迟到
        }else {
            return 2;//缺勤
        }
    }
}
